package com.yueyang.sojourn.server.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author yemingxing
 * @summary 上架状态 枚举
 * @Copyright (c) 2020, Yueyang Group All Rights Reserved.
 * @since 2020-02-13
 */
@AllArgsConstructor
public enum ShelfStatusEnum implements IEnum {
    /**
     * 上架状态 枚举
     */
    TO_BE_ON(0, "待上架"),
    BEING_ON(1, "上架中"),
    OFF(9, "已下架"),
    ;

    @Getter
    private int code;

    @Getter
    private String desc;

    public static ShelfStatusEnum ofCode(Integer shelfStatus) {
        return Arrays.stream(ShelfStatusEnum.values())
                .filter(shelfStatusEnum -> shelfStatusEnum.code == shelfStatus)
                .findFirst().orElse(null);
    }
}
